var FormgroupSelector = '.formgroup';
var CmsFormGroupControl = Class.create(GridControl, {
    selector:FormgroupSelector,

    observeEvent: function($super)
    {
        $super();
        this.form = this.down('form');
        this.find('.cbutton.edit', '.cbutton.cancel').invoke('observe', 'click', this.buttonEdit.bind(this));
        this.find('.cbutton.submit').invoke('observe', 'click', this.buttonSave.bind(this));
    },

    buttonEdit: function()
    {
        this.find('.cbutton.edit', '.cbutton.cancel').invoke('toggle');
        this.editSelected();
    },

    buttonSave: function()
    {
        this.find('.cbutton.edit').invoke('show');
        this.find('.cbutton.cancel').invoke('hide');
    },

    submit: function($super)
    {
        if (this.view.hasClassName('noAjax'))
            this.form.submit();
        else $super();
    },

});